package com.kogi.androidpatt.gettingInput.enterValue;

import java.util.ArrayList;

import com.kogi.patterns.R;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Layout;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;

public class spinner extends Activity
{
	 private static final String[] colors =
	 { 		  
		 "BLUE",
		 "BLACK", 
		 "CYAN", 
		 "GRAY",
		 "GREEN",   
		 "MAGENTA",  
		 "RED",  
		 "WHITE",
	  	 "YELLOW"
	  };
	 
	 private TextView colorBox,colorBox2,colorBox3;
	 private Spinner spinner1,spinner2,spinner3;
	
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
        setContentView(R.layout.getting_input_spinner);
        spinner1 = (Spinner) findViewById(R.id.spinner1);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, colors);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        spinner1.setAdapter(adapter);
        colorBox = (TextView)findViewById(R.id.colorBoxSpinner1); 
        spinner1.setOnItemSelectedListener
        (
        		new Spinner.OnItemSelectedListener()
        		{
        			@Override
        			public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) 
        			{
        				colorBox.setBackgroundColor(Color.parseColor(spinner1.getSelectedItem().toString()));
        			}

			         @Override
			         public void onNothingSelected(AdapterView<?> arg0) 
			         {       
			        	 
			         }
			     }
        );
        spinner2 = (Spinner) findViewById(R.id.spinner2);
        ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, colors);
        adapter2.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
        spinner2.setAdapter(adapter2);
        spinner2.setSelection(3);
        colorBox2 = (TextView)findViewById(R.id.colorBoxSpinner2); 
        spinner2.setOnItemSelectedListener
        (
        		new Spinner.OnItemSelectedListener()
        		{
        			@Override
        			public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) 
        			{
        				colorBox2.setBackgroundColor(Color.parseColor(spinner2.getSelectedItem().toString()));
        			}

			         @Override
			         public void onNothingSelected(AdapterView<?> arg0) 
			         {       
			        	 
			         }
			     }
        );
        
        spinner3 = (Spinner) findViewById(R.id.spinner3);
        ArrayAdapter<String> adapter3 = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, colors);
        adapter3.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
        spinner3.setAdapter(adapter3);
        spinner3.setSelection(4);
        colorBox3 = (TextView)findViewById(R.id.colorBoxSpinner3); 
        spinner3.setOnItemSelectedListener
        (
        		new Spinner.OnItemSelectedListener()
        		{
        			@Override
        			public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) 
        			{
        				colorBox3.setBackgroundColor(Color.parseColor(spinner3.getSelectedItem().toString()));
        			}

			         @Override
			         public void onNothingSelected(AdapterView<?> arg0) 
			         {       
			        	 
			         }
			     }
        );
        
	}
	
//	protected void createSpinnerAndBox(Spinner sp,TextView box,int idSp,int idBx,int layoutAdapter)
//	{
//		sp = (Spinner) findViewById(idSp);
//        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, colors);
//        adapter.setDropDownViewResource(layoutAdapter);
//        sp.setAdapter(adapter);
//        box = (TextView)findViewById(idBx); 
//        sp.setOnItemSelectedListener
//        (
//        		new Spinner.OnItemSelectedListener()
//        		{
//        			@Override
//        			public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) 
//        			{
//        				colorBox2.setBackgroundColor(Color.parseColor(spinner2.getSelectedItem().toString()));
//        			}
//
//			         @Override
//			         public void onNothingSelected(AdapterView<?> arg0) 
//			         {       
//			        	 
//			         }
//			     }
//        );
//	}
	
}
